<?php
/**
 * User: VeXell
 * Date: 11.08.11
 * Time: 0:36
 */


error_reporting(E_ALL);
ini_set('display_errors', true);
date_default_timezone_set('Europe/London');

define('KEN_PLUGIN_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
define('KEN_FONT_DIR', KEN_PLUGIN_DIR . 'cache' . DIRECTORY_SEPARATOR . 'font' . DIRECTORY_SEPARATOR);

mb_internal_encoding('utf-8');

$name = urldecode($_GET['name']);

if (empty($name)) {
    $name = '';
}

$fontType = KEN_FONT_DIR . 'tahoma.ttf';
header( "Content-type: image/png" );

$font  = 8;
$width  = mb_strlen($name) + (mb_strlen($name) * 5.8);
$height = ImageFontHeight($font) - 3;
$im = imagecreatetruecolor ($width, $height);

$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);

imagefilledrectangle($im, 0, 0, $width, $height,$white );
imagettftext($im, $font, 0, 1, 10, $black, $fontType, $name);

imagepng($im);
imagedestroy($im);